<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="managesystem.Student" %>
<%@ page import="learninganalytics.Register" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link href="/styles/style.css" rel="stylesheet" type="text/css">
    
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
    <%
	Register.init(); //objectify requires to register entity classes
	String message = (String) session.getAttribute("message");
	String error = (String) session.getAttribute("error");
	session.setAttribute("message",null);
	session.setAttribute("error",null);
	
	%>
    <title>Learning Application</title>
   	
	<%
		Student currStud = (Student) session.getAttribute("currStud");
	%>
	  
  </head>

  <body>
  	<div id="header">
  		<div class="logo"><a href="http://studyanalyse.appspot.com">Learning Application</a></div>
  		<% if(currStud == null){
  				pageContext.include("inc/loginpanel.jsp");
  			}
  		  	else{
  			  	
  		  		pageContext.include("inc/logout.jsp");
  		  }
  		%>
  	</div>
  	
	<div id="main">
	<ul id="horizontaleNav">
			<li class="tab"><a href="/index.jsp?id=home">Home</a></li>
			<li class="tab"><a href="#">Dashboard</a></li>
			<li class="tab"><a href="/index.jsp?id=ucp">User ControlPanel</a></li>
			<li class="tab"><a href="/index.jsp?id=about">About</a></li>
			<li class="tab"><a href="Plot/plot.jsp">Toon Plot</a></li>
			<li class="tab"><a href="/index.jsp?id=milestones">Milestones</a></li>
			<li class="tab"><a href="/index.jsp?id=track">Track</a></li>
		</ul>
		<%
		String pageID = request.getParameter("id");
		ArrayList<String> pages = new ArrayList<String>();
		pages.add("home");
		pages.add("about");
		pages.add("register");
		pages.add("milestones");
		pages.add("start");
		pages.add("ucp");
		pages.add("track");
		pages.add("school");
		pages.add("other");

		
		if (currStud != null) {
			
			if(pageID == null){
				
				pageContext.include("/inc/home.jsp");
				
			}
			else if(pages.contains(pageID)){
				pageID="/inc/"+pageID+".jsp";
				pageContext.include(pageID);
			}
			
			else{
				pageContext.include("/inc/404.jsp");
			}
			
        } else {
        	
        	if(pageID != null && pageID.equals("register")){
        		pageContext.include("/inc/register.jsp",true);
        	}
        	else{
        		pageContext.include("/inc/login.jsp",true);
        	}
        }
		%>
	</div>
	<div class=footer>
		<p>Copyright (c) All Rights Reserved. Team CWA2 & <a href="http://www.kuleuven.be" target=_blank>KU Leuven</a></p>
		<p>This site is best viewed with <a href="http://www.mozilla.org/en-US/firefox/new/" target=_blank>Firefox</a> or <a href="http://www.google.com/chrome/index.html?hl=en&brand=CHMB&utm_campaign=nl&utm_source=nl-ha-emea-be-sk&utm_medium=ha" target=_blank>Chrome</a></p>
	</div>
  </body>
</html>